<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    // 分割数组
    const listChunk = (list, size = 1) => {
      const tmp = [...list]
      let cacheList = []
      if (size <= 0) {
        return cacheList
      }
      while (tmp.length) {
        cacheList.push(tmp.splice(0, size))
      }
      return cacheList
    }
    let arr = [1, 2, 3, 4, 5, 6]
    console.log(listChunk(arr, 3)); // [[1,2,3], [4,5,6]]
  </script>
</body>

</html>